package net.linxuehua.server.controller.admapi;/**
 * @author chenyan
 * @createTime 2021/1/12 9:42
 * @description description
 */

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.linxuehua.commons.core.R;
import net.linxuehua.server.po.Food;
import net.linxuehua.server.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Slf4j
@Api(tags = {"食材接口"})
@RestController
@RequestMapping(value = "/admapi/food")
public class FoodController {
    @Autowired
    private FoodService foodService;

    @ApiOperation(value = "查找食材信息")
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable Integer id) {
        Food food = foodService.getById(id);
        return R.data(food);
    }

    @ApiOperation(value = "查找所有食材信息")
    @GetMapping(value = "/getAllInfo")
    public R getAllInfo() {
        List<Food> foodList = foodService.list();
        return R.data(foodList);
    }

}
